package com.xingchen.feima.system.mapper;

import com.xingchen.feima.system.entity.Menu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 菜单表 Mapper 接口
 * </p>
 *
 * @author yangxc
 * @since 2024-07-27
 */
@Mapper
public interface MenuMapper extends BaseMapper<Menu> {

    @Select("select distinct m.id,m.parent_id,m.name,m.type,m.route_path," +
            "                m.component_path,m.perms,m.icon,m.sort_value,m.status," +
            "                m.create_time,m.update_time from system_menu m inner join system_role_menu rm on rm.menu_id = m.id" +
            "            inner join system_user_role ur on ur.role_id = rm.role_id" +
            "            where ur.user_id = #{userId} and m.status = 1 order by sort_value;")
    List<Menu> findMenuListByUserId(Long userId);
}
